<!--门诊费用列表-->
<template>
	<view>
		<view class="top_select_box">
			<view class="top_select">
				<view class="left"><b @click="selectPerson">{{userData.xming0}}</b>的门诊缴费记录</view>
				<view class="edit_icon left" @click="selectPerson"></view>
				<view class="right" @click="selectTime"><span>{{timeData.title}}</span><view class="select_icon right"></view></view>
			</view>
		</view>
		<view class="box_content">
			<ul>
				<li v-for="(item,index) in dataList" :key="index" @click="selectRecord(index)" :style="item.styles">
					<view style="padding-bottom: 10px;">
						<view class="numbers">
							<h4>{{item.ylmc00}} {{item.jfdjh0}}</h4>
						</view>
						<view>
							<p>诊断日期：{{item.jssfrq}}</p>
						</view>
						<view>
							<p>开单医生：{{item.ysxm00}}</p>
						</view>
						<view>
							<p>科室：{{item.ksmc00}}</p>
						</view>
						<view>
							<p>合计费用：{{item.bcfyze}}元</p>
						</view>
					</view>
					<view style="">
						<hr />
					</view>
					<view class="btns list_footer">
						<!-- <button class="box_btn pay_btn" @click.stop="payment(item)">微信支付</button> -->
						<button class="box_btn cancel" @click.stop="detail(item)">查看详情</button>
					</view>
				</li>
			</ul>
			<view style="height: 90px;position: relative;bottom: 0px;float: left;width: 100%;">
				<view class="footer">
					<view class="total_money">总计金额:<b>{{total}}</b></view>
				</view>
			</view>
		</view>
		<personList styles="display:none;" ref="personList" v-on:checkedPerson= "getDatas"></personList>
		<dateTimeSelect styles="display:none;" ref="dateTimeSelect" v-on:checked= "getTime"></dateTimeSelect>
	</view>
</template>

<script>
	import personList from "../../modules/personList.vue";
	import dateTimeSelect from "../../modules/dateTimeSelect.vue";
	import pay from "@/tool/pay.js";
	export default {
		data() {
			return {
				total:0,
				userData:{"xming0":""},
				dataList:[],
				checkItem:[],
				timeData:{},
			}
		},
		components:{
			personList,dateTimeSelect
		},
		onLoad(option) {
			if(option.mzh000&&option.kh0000){
					//查询相关人的信息
			}
			
			
		},
		methods: {
			init(user){
				this.userData=user;
				//查看门诊处方单
				let params={
					kh0000:user.sfzh00,
					klx000:"3",
					patid0:user.patid0,
					ksrq00:this.timeData.startDate,
					jzrq00:this.timeData.endDate,
					funid:"F07.07.02.01"
				}
				uni.showLoading({
					mask:true,
					title:"数据加载中..."
				})
				this.$postJson("/qnyesb/qnyesbproxy",params,res=>{
					if(res.state==0){
						let data=res.data.retrieve;
						this.dataList=data;
						this.total=0;
						for(let item in data){
							this.total+=parseFloat(data[item].bcfyze);
						}
					}else{
						this.dataList=[];
						let _this=this;
						uni.showModal({
							title:"温馨提示",
							content:res.message+"~点击确定返回首页",//queryRes.message
							mask:true,
							cancelText:"其他就诊人",
							success(showRes) {
								if(showRes.confirm){
									uni.switchTab({
										url:"../index/index"
									})
								}else{
									_this.selectPerson();
								}
							}
						})
					}
					uni.hideLoading();
				})
			},
			selectRecord(index){
				return;
				//记录选中，进入详情页
				let checkItem=this.checkItem;
				if(this.dataList[index].styles){
					this.dataList[index].styles="";
					checkItem.forEach((item, i) => {
					  if (item == index) {
						checkItem.splice(i, 1); // 从下标 i 开始, 删除 1 个元素
					  }
					})
				}else{
					this.dataList[index].styles="background:#e7e7e7;";
					checkItem.push(index);
				}
				//总算
				let total=0;
				for(let item in checkItem){
					let data=this.dataList[checkItem[item]];
					let bcfyze=parseFloat(data.bcfyze);
					total+=bcfyze;
				}
				this.total=total;
				console.log(total);
			},
			selectTime(){
				this.$refs.dateTimeSelect.select();
			},
			getTime(item){
				console.log(item);
				this.timeData=item;
				let user=uni.getStorageSync("user");
				this.init(user);
			},
			detail(item){
				let user=this.userData;
				uni.navigateTo({
					url:"clinicPayDetail",
					success(res) {
						res.eventChannel.emit("params",item);
					}
				})
			},
			selectPerson(){
				this.$refs.personList.selectPerson();
			},
			getDatas(item){
				this.userData=item;
				this.init();
			},
		}
	}
</script>

<style>
	.box_content {
		width: 96%;
		margin: 0 auto;
	}
	.box_content .numbers{
		border-bottom: 1px solid #F0F0F0;
	}
	.box_content p {

		color: #999999;
	}

	.box_content hr {
		border: 1px solid #F0F0F0;
	}

	.box_content ul li {
		width: 89%;
		background-color: #FFFFFF;
		padding: 20px;
		margin-top: 10px;
		display: inline-block;
		line-height: 30px;
		padding-bottom: 10px;
	}

	.box_content .btns {
		margin-top: 10px;
	}

	.box_content .btns .box_btn {
		width: 94px;
		height: 30px;
		border-radius: 15px;
		font-size: 14px;
		border: none;
		float: right;
		line-height: 30px;
		margin-right: 10px;
	}

	.box_content .btns .pay_btn {
		background-color: #3692FF;
		color: #FFFFFF;
		margin-right: 0px;
	}

	.list_footer {
		padding-top: 5px;
	}
	.footer{
		width: 100%;
		position: fixed;
		height: 80px;
		line-height: 80px;
		bottom: 0;
		left: 0;
		background-color: #FFFFFF;
		box-shadow: 5px 0px 5px #464646;
	}
	.footer .total_money{
		float: left;
		margin-left: 20px;
	}
	.footer .box_btn{
		width: 120px;
		height: 40px;
		line-height: 40px;
		font-size: 16px;
		background-color: #00A500;
		color: #FFFFFF;
		float: right;
		margin-right: 20px;
		margin-top: 20px;
	}
</style>
